//
//  DeletView.m
//  RONGAO
//
//  Created by wei wang on 2017/3/15.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DeletView.h"

@implementation DeletView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self configView];
    }
    return self;
}

- (void)configView{
    
    __weak UIView *superView = self;
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(superView.mas_right);
        make.left.mas_equalTo(superView.mas_left);
        make.top.mas_equalTo(superView.mas_top);
        make.height.mas_equalTo(0.6);
        
    }];
    
    [self.delet mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.centerY.mas_equalTo(superView.mas_centerY).mas_offset(-8);
        make.width.mas_equalTo(superView);
        make.height.mas_equalTo(superView);
        
    }];
    [self.delet setTitleEdgeInsets:UIEdgeInsetsMake(_delet.imageView.frame.size.height+18 ,-_delet.imageView.frame.size.width-18, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变

}

- (UIView *)lineView{
    
    if (!_lineView) {
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"e2e2e2"];
        
        [self addSubview:_lineView];
    }
    return _lineView;
}

- (UIButton *)delet{
    
    if (!_delet) {
        
        _delet = [UIButton buttonWithType:UIButtonTypeCustom];
        [_delet setImage:[UIImage imageNamed:@"photo_icon_delete"] forState:UIControlStateNormal];
        [_delet setTitle:@"删除" forState:UIControlStateNormal];
        [_delet.titleLabel setFont:[UIFont systemFontOfSize:10]];
        [_delet setTitleColor:[UIColor colorWithRed:55/255.f green:50/255.f blue:27/255.f alpha:1.0f] forState:UIControlStateNormal];
        [_delet addTarget:self action:@selector(deletBtnEvent) forControlEvents:UIControlEventTouchUpInside];
      
        [self addSubview:_delet];
    }
    return _delet;
}

- (void)deletBtnEvent{
    NSLog(@"删除事件");

    if (self.deletEvent) {
        
        self.deletEvent();
    }

}




@end
